<template>
  <div class="con">
    <div class="contbox6_10">
      <p class="titlelist6_10">
        账户管理
        <span style="color: #999">&nbsp;&nbsp;/&nbsp;&nbsp;</span>通道管理 /
        支持银行
      </p>
    </div>
    <div class="formsTwo">
      <p>业务信息</p>
      <div class="borders"></div>
      <el-form ref="forms" :model="forms" label-width="140px">
        <el-form-item label="开启状态">
          <el-select v-model="submitList.status" placeholder>
            <el-option label="开启" value="0"></el-option>
            <el-option label="关闭" value="1"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="银行卡类型">
          <el-select
            v-model="submitList.cardType"
            placeholder="请选择银行卡类型"
            @change="list"
          >
            <el-option label="借记卡" value="0"></el-option>
            <el-option label="贷记卡" value="1"></el-option>
            <el-option label="借记卡+贷记卡" value="2"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="支持银行">
          <!-- <el-input v-model="submitList.bankName"></el-input> -->
          <el-select
            @change="bankList"
            v-model="submitList.bankName"
            placeholder
          >
            <el-option
              v-for="item in options"
              :key="item.bankCode"
              :label="item.bankName"
              :value="[item.bankCode, item.bankName]"
            >
            </el-option>
          </el-select>
        </el-form-item>

        <el-form-item label="机构d0交易费率 "
          >&nbsp;&nbsp;&nbsp;&nbsp;
          <el-input v-model="submitList.d0TradeRate"></el-input>%
        </el-form-item>
        <el-form-item label="d0手续费 "
          >&nbsp;&nbsp;&nbsp;&nbsp;
          <el-input v-model="submitList.d0DrawFee"></el-input>元
        </el-form-item>
        <el-form-item label="单笔最低限额 "
          >&nbsp;&nbsp;&nbsp;&nbsp;
          <el-input v-model="submitList.singleLowest"></el-input>元
        </el-form-item>
        <el-form-item label="单笔最高限额 "
          >&nbsp;&nbsp;&nbsp;&nbsp;
          <el-input v-model="submitList.singleLimit"></el-input>元
        </el-form-item>
        <el-form-item label="单卡单日限额 "
          >&nbsp;&nbsp;&nbsp;&nbsp;
          <el-input v-model="submitList.dayLimit"></el-input>元
        </el-form-item>
        <el-form-item label="单卡单月限额 "
          >&nbsp;&nbsp;&nbsp;&nbsp;
          <el-input v-model="submitList.monthLimit"></el-input>元
        </el-form-item>
        <!-- <el-form-item label="交易笔数限制 "
          >&nbsp;&nbsp;&nbsp;&nbsp;
          <el-input v-model="submitList.mechanismNo"></el-input>元
        </el-form-item> -->
        <el-form-item>
          <el-button type="primary" @click="submit">保存</el-button>
          <el-button @click="back">取消</el-button>
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>
<script>
import axios from "axios";
export default {
  data() {
    return {
      formsDisplay: true,
      form: {
        region: "",
      },
      forms: {
        mechanismNo: "",
      },
      formes: {
        region: "",
      },
      options: null,
      submitList: {
        id: "",
        channelCode: "", //通道编号
        busCode: "", //支付业务编码
        bankCode: "", //银行编号
        bankName: "", //银行名称
        cardType: "", //卡类型
        d0DrawFee: "", //平台D0提现费
        d0TradeRate: "", //平台d0交易费率
        singleLowest: "", //单笔最低限额
        singleLimit: "", //单笔最高限额
        dayLimit: "", //日交易限额
        monthLimit: "", //月交易限额
        status: "", //业务状态
      },
    };
  },
  created() {
    this.submitList.channelCode = this.$route.query.channelCode;
    axios
      .post("/api/channel/saveBank", {})
      .then((res) => {
        console.log(res);
      })
      .catch((err) => {
        console.log(err);
      });
    //获取支持银行
    axios
      .get("/bank/queryBank")
      .then((res) => {
        // alert("获取支持银行成功")
        console.log(res);
        this.options = res.data.data;
      })
      .catch((err) => {
        console.log(err);
      });
    var id = this.$route.query.id;
    // alert(id)
    console.log("下面是回显数据");
    let boos = this.$route.query.disb
    if (boos == "y") {
      axios
        .post("/api/channel/updateById", { id: id })
        .then((res) => {
          console.log(res);
          this.submitList = res.data.data;
          // this.$router.go(-1)
        })
        .catch((err) => {
          console.log(err);
        });
    }
  },
  methods: {
    // 开通业务选择
    list(event, item) {
      console.log(event);
      if (event != 0) {
        this.formsDisplay = false;
      }
    },
    success() {
        this.$message({
          message: '成功',
          type: 'success'
        });
      },
    submit() {
      //获取通道编号
      if (this.submitList.channelCode != "") {
        axios
          .post("/api/channel/saveBank", this.submitList)
          .then((res) => {
            // alert("创建成");
            console.log(res);
            this.success()
            setTimeout(() => {
              this.$router.go(-1)
            }, 500);
            
          })
          .catch((err) => {
            console.log(err);
          });
      }
    },
    bankList(val) {
      console.log(val);
      this.submitList.bankCode = val[0];
      // alert(this.submitList.bankCode)
      this.submitList.bankName = val[1];
    },
    back(){
      this.$router.go(-1)
    }
  },
};
</script>
<style scoped>
.con {
  padding: 20px;
  /* display: flex;
    flex-direction: column */
}
.contbox6_10 {
  width: 96%;
  min-height: 10px;
  margin-left: 2%;
  height: 85px;
  overflow-x: auto;
  box-sizing: border-box;
  float: left;
}
.titlelist6_10 {
  width: 100%;
  float: left;
  font-size: 16px;
  color: #222;
  margin-top: 40px;
}
.select {
  float: left;
  width: 100%;
  margin-left: 2%;
  margin-top: 20px;
}
.forms {
  float: left;
  width: 100%;
  margin-left: 2%;
  margin-top: 20px;
}
.el-input {
  width: 266px;
}
/deep/ .el-input__inner{
  width: 266px;
}
.formsTwo {
  float: left;
  width: 100%;
  margin-left: 2%;
  margin-top: 20px;
}
p {
  font-size: 16px;
}
.borders {
  border-bottom: 2px solid #ccc;
  margin-bottom: 15px;
  margin-top: 20px;
}
</style>
